<template>

  <div id="app">

<!--    <div>-->
<!--&lt;!&ndash;      <IndexView></IndexView>&ndash;&gt;-->
<!--          <router-view/>-->
<!--    </div>-->
        <router-view/>
  </div>
</template>
<script>
import { getUserInfo} from "@/api/http";
// import {Toast} from "vant";
// import IndexView from "@/views/IndexView";
export default {
components:{
  // IndexView
},
  data(){
    return {
      // flagTwo:true,
      // n:5,
      timer:null,
    }
  },
  methods:{
    autoPlay(){
      setInterval(this.play,1000)
    },
    play(){
      this.n--
      if(this.n == 0){
        this.flagTwo = false;
        this.$router.push({path:'/indexView'})
      }
    }
  },
  mounted() {
    this.autoPlay()
  }
,
  created() {
    // 判断计时器是否清零
    if (this.$store.state.count < 0) {
      this.$store.commit('changeShow',true);
      // console.log(this.$store.state.count)
    } else {
      this.$store.commit('changeShow',false)
      // console.log(sessionStorage.getItem('X_no_time'))
      this.$store.commit('getCount',sessionStorage.getItem('X_no_time'))
      this.timer = setInterval(() => {
        if (this.$store.state.count > 0 && this.$store.state.count <= 60) {
          this.$store.commit('changeCount');
          this.$store.getters.getMyCount;
        } else {
          this.$store.commit('changeShow',true);
          // this.show = true;
          clearInterval(this.timer);
          this.timer = null;
        }
      }, 1000)
      // this.$store.commit('changeCount')
      // console.log(this.$store.state.count)
    }
  //  登录状态
    getUserInfo().then(res=>{
      if(res.code==0){
        // console.log(res)
        this.$store.commit('changeUserInfo',res.data);
        this.$store.commit('changeLogin',true);
      }
    })

  },


}
</script>


